package com.mrogrape.notepad.activity.action.item;

import java.awt.event.ActionEvent;
import java.util.List;

import javax.swing.AbstractAction;
import javax.swing.Action;

import com.mrogrape.notepad.data.ViewContext;
import com.mrogrape.notepad.ui.ClosableTabPanel;


public class CloseAllMenuItemAction extends AbstractAction{

	/** serialVersionUID */
	private static final long serialVersionUID = -1L;

	public CloseAllMenuItemAction(){

		super.putValue(Action.NAME, "Close All");
		super.putValue(Action.SHORT_DESCRIPTION, "Close All Tabs");
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {

		List<ClosableTabPanel> tabs = ViewContext.getMainFrame().getAllWorkPanels();

		for(ClosableTabPanel tab : tabs){

			ViewContext.getMainFrame().closeWorkPanel(tab);
		}
	}
}
